package com.z.xviewpager;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.z.xviewpager.xviewpager.XAdapter;

import java.util.List;

/**
 * Created by z
 * on 2017/11/19 0019.
 */

public class TestAdapter extends XAdapter {

    private List<String> mData;

    public TestAdapter(List<String> data) {
        this.mData = data;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView textView = new TextView(parent.getContext());
        textView.setBackgroundColor(0xFF888888);
        textView.setText(mData.get(position));
        return textView;
    }

    @Override
    public int getSize() {
        return mData.size();
    }

    @Override
    public int getPreviousPosition(int position) {
        return position == 0 ? getSize() - 1 : position - 1;
        //return super.getPreviousPosition(position);
    }

    @Override
    public int getNextPosition(int position) {
        return position == getSize() - 1 ? 0 : position + 1;
        //return super.getNextPosition(position);
    }
}
